<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of User
 *
 * @author Gael
 */
class User {
    public $id;
    public $nom;
    public $pwd;
    
    function __construct($id, $nom, $pwd) {
        $this->id = $id;
        $this->nom = $nom;
        $this->pwd = $pwd;
    }
    public function getId() {
        return $this->id;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function getNom() {
        return $this->nom;
    }

    public function setNom($nom) {
        $this->nom = $nom;
    }

    public function getPwd() {
        return $this->pwd;
    }

    public function setPwd($pwd) {
        $this->pwd = $pwd;
    }

static public function all(){
        try{
            $db= getPdo();
            $tab = array();
            
            $rep = $db->query("select * from user " );
            while($data =$rep->fetch()){
                $tab[$data['id']]=new User($data['id'], $data['nom'], $data['pwd']);
            }
            $rep->closeCursor();
            return $tab;
        }catch(Exception $e){
            die('erreur requete'.$e->getMessage());
        }
    } 
}

?>
